package view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

public class ToolsPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	private String strTool;
	private int width;
	private int height;
	private String[] buttons = { "Line", "Circle" };

	public ToolsPanel(int width, int height) {
		// TODO Auto-generated constructor stub
		this.width = width;
		this.height = height;
		this.strTool = buttons[0];
		init();
	}

	public void init() {
		// TODO Auto-generated method stub
		setSize(new Dimension(this.width, this.height));
		setBackground(Color.LIGHT_GRAY);
		setLayout(new GridLayout(10, 1));

		ActionListener action = new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				strTool = e.getActionCommand();
			}
		};

		for (String button : buttons) {
			JButton jbtn = new JButton(button);
			jbtn.setFont(new Font("宋体", Font.PLAIN, 20));
			jbtn.setActionCommand(button);
			jbtn.addActionListener(action);
			this.add(jbtn);
		}
	}

	public String getTool() {
		return this.strTool;
	}
}
